<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>⿏标点击⻚⾯出现随机颜⾊的⽂字，出现之后向上淡出。</title>
  <style>
    span {
      font-size: 20px;
      position: absolute;
      margin-top: 300px;
      margin-left: 750px;
      transition: 1s;
    }
  </style>
</head>

<body>
  <script>
    // 设置随机出现的文字数组
    var arr = ["何", "温", "万", "秋", "自", "的", "山", "崩", "过", "相"]
    document.onclick = function (x) {
      // 创建元素节点对象
      var span = document.createElement("span")
      span.innerHTML = arr[Math.floor(Math.random() * arr.length)]
      // 设置span的动画效果
      setTimeout(function () {
        span.style.opacity = "0"
        span.style.transform = "translateY(-200px)"
      }, 100)
      // 将span添加到body里
      document.body.appendChild(span)
    }
  </script>
</body>

</html>